<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <cc:interface>
        <cc:attribute name="collapsible" default="false" />
     </cc:interface>

    <cc:implementation>
        <ui:fragment rendered="#{not empty flash['successMsg']}">
            <div class="alert alert-success">
                <span class="glyphicon glyphicon glyphicon-ok-sign"></span>&#160;<strong>#{bundle['messages.success']}</strong> – <h:outputText escape="false" value="#{flash['successMsg']}"/>
            </div>
        </ui:fragment>
        <ui:fragment rendered="#{not empty flash['errorMsg']}">
            <div class="alert alert-danger">
                <o:form useRequestURI="true">
                    <span class="glyphicon glyphicon-warning-sign"></span>&#160;<strong>#{bundle['messages.error']}</strong> – 
                    <h:outputText value="#{flash['errorMsg']} " escape="false"/>
                    <h:outputFormat value="#{bundle['error.support.message']}" escape="false">
                        <o:param>
                            <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                            </p:commandLink>                                
                        </o:param>
                    </h:outputFormat>
                </o:form>
            </div>
        </ui:fragment>
        <ui:fragment rendered="#{not empty flash['infoMsg']}">
            <div class="alert alert-info">
                <span class="glyphicon glyphicon-info-sign"></span>&#160;<strong>#{bundle['messages.info']}</strong> – <h:outputText escape="false" value="#{flash['infoMsg']} "/>
            </div>
        </ui:fragment>
        <ui:fragment rendered="#{not empty flash['warningMsg']}">
            <div class="alert alert-warning">
                <span class="glyphicon glyphicon-exclamation-sign"></span>&#160;<strong>#{bundle['messages.info']}</strong> – <h:outputText escape="false" value="#{flash['warningMsg']} "/>
            </div>
        </ui:fragment>
        <ui:fragment rendered="#{facesContext.validationFailed}">
            <div class="alert alert-danger">
                <span class="glyphicon glyphicon-warning-sign"></span>&#160;<strong>#{bundle['messages.validation']}</strong> – #{bundle['messages.validation.msg']}
            </div>
        </ui:fragment>
        <ui:repeat rendered="#{!facesContext.validationFailed}" value="#{facesContext.messageList}" var="msg">
            #{level = fn:split(msg.severity,' ')[0]; "" }
            #{bsClass = (level eq 'INFO' ? 'info' : (level eq 'WARN' ? 'warning' : 'danger')); ""}
            #{bsIcon = (level eq 'INFO' ? 'info' : (level eq 'WARN' ? 'exclamation' : 'warning')); ""}
            <div class="alert #{cc.attrs.collapsible ? 'alert-dismissable' :''} alert-#{bsClass}">
                <ui:fragment rendered="#{cc.attrs.collapsible}">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                </ui:fragment>
                <span class="glyphicon glyphicon-#{bsIcon}-sign"></span>&#160;<strong>#{msg.summary}</strong> – <h:outputText escape="false" value="#{msg.detail}" rendered="#{!empty msg.detail and (msg.detail != msg.summary)}"/>
                <ui:fragment rendered="#{level eq 'FATAL'}">
                    Please contact <a href="#" onclick="event.preventDefault();PF('contactForm').show();" title="Contact #{settingsWrapper.supportTeamName}">#{settingsWrapper.supportTeamName}</a> for assistance.
                    <strong>Date/Time: </strong>
                    <h:outputText value="#{now}">
                        <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" type="date" />
                    </h:outputText>
                    <strong>Server: </strong>
                    #{systemConfig.dataverseServer}
                </ui:fragment>
            </div>
            #{msg.rendered()}
        </ui:repeat>
    </cc:implementation>
</html>
